﻿using System;
using System.ComponentModel.DataAnnotations;

namespace Diploma.Models.Valildation.CustomAttributes
{
    internal class DateTimeAttribute : ValidationAttribute
    {
        public override bool IsValid(object value)
        {
            if (value == null)
            {
                return false;
            }

            DateTime convertedValue;
            try
            {
                convertedValue = Convert.ToDateTime(value);
            }
            catch (FormatException)
            {
                return false;
            }

            return true;
        }
    }
}